=========== Unit System =========== LouLib provides unit classes and methods for doing unit conversions and dimensional analysis Using Units =========== Creating a new quantity ----------------------- A quantity can be created by multiplying the desired amount by the desired unit: .. code-block:: cpp //create a length of 5 meters LouLib::Units::Length length = 5.0 * LouLib::Units::METER; When declaring a new quantity, string literals can also be used to declare the desired unit. However, string literals can only be used when the desired amount is not a variable. The following code does the same thing as the above code: .. code-block:: cpp //create a length of 5 meters LouLib::Units::Length length = 5.0_m; A full list of units and their corresponding string literals can be found near the bottom of this page. Performing unit conversions --------------------------- Unit conversions can be performed using the :code:`to` method: .. code-block:: cpp //create a length of one foot LouLib::Units::Length length = 1_ft; //convert to inches and centimeters double lengthInInches = length.to(LouLib::Units::INCH); double lengthInCentimeters = length.to(LouLib::Units::CENTIMETER); After running the example above, the value of :code:`lengthInInches` should be 12, and the value of :code:`lengthInCentimeters` should be 0.3048. Dimensional analysis -------------------- List of Units ============= .. table:: :widths: 100 100 100 +------------------------------+------------------------------+------------------------------+ |Quantity Type |Unit Name |String Literal | +==============================+==============================+==============================+ | **Length** |METER |_m | + +------------------------------+------------------------------+ | |DECIMETER |_dm | + +------------------------------+------------------------------+ | |CENTIMETER |_cm | + +------------------------------+------------------------------+ | |MILLIMETER |_mm | + +------------------------------+------------------------------+ | |INCH |_in | + +------------------------------+------------------------------+ | |FOOT |_ft | + +------------------------------+------------------------------+ | |YARD |_yd | + +------------------------------+------------------------------+ | |TILE |_tl | +------------------------------+------------------------------+------------------------------+ | **Mass** |KILOGRAM |_kg | + +------------------------------+------------------------------+ | |HECTOGRAM |_hg | + +------------------------------+------------------------------+ | |DECAGRAM |_dag | + +------------------------------+------------------------------+ | |GRAM |_g | + +------------------------------+------------------------------+ | |OUNCE |_oz | + +------------------------------+------------------------------+ | |POUND |_lb | +------------------------------+------------------------------+------------------------------+ | **Time** |SECOND |_s | + +------------------------------+------------------------------+ | |DECISECOND |_ds | + +------------------------------+------------------------------+ | |CENTISECOND |_cs | + +------------------------------+------------------------------+ | |MILLISECOND |_ms | + +------------------------------+------------------------------+ | |MINUTE |_min | + +------------------------------+------------------------------+ | |HOUR |_hr | +------------------------------+------------------------------+------------------------------+ | **Current** |AMPERE |_A | + +------------------------------+------------------------------+ | |KILOAMPERE |_kA | + +------------------------------+------------------------------+ | |HECTOAMPERE |_hA | + +------------------------------+------------------------------+ | |DECAAMPERE |_daA | + +------------------------------+------------------------------+ | |DECIAMPERE |_dA | + +------------------------------+------------------------------+ | |CENTIAMPERE |_cA | + +------------------------------+------------------------------+ | |MILLIAMPERE |_mA | +------------------------------+------------------------------+------------------------------+ | **Temperature** |KELVIN |_K | +------------------------------+------------------------------+------------------------------+ | **Substance** |MOLE |_mol | +------------------------------+------------------------------+------------------------------+ | **Luminosity** |CANDELA |_cd | +------------------------------+------------------------------+------------------------------+ | **Angle** |RADIAN |_rad | + +------------------------------+------------------------------+ | |DEGREE |_deg | + +------------------------------+------------------------------+ | |DECIDEGREE |_ddeg | + +------------------------------+------------------------------+ | |CENTIDEGREE |_cdeg | +------------------------------+------------------------------+------------------------------+ | **Area** |SQUARE_METER |_m2 | + +------------------------------+------------------------------+ | |SQUARE_DECIMETER |_dm2 | + +------------------------------+------------------------------+ | |SQUARE_CENTIMETER |_cm2 | + +------------------------------+------------------------------+ | |SQUARE_MILLIMETER |_mm2 | + +------------------------------+------------------------------+ | |SQUARE_INCH |_in2 | + +------------------------------+------------------------------+ | |SQUARE_FOOT |_ft2 | + +------------------------------+------------------------------+ | |SQUARE_YARD |_yd2 | + +------------------------------+------------------------------+ | |SQUARE_TILE |_tl2 | +------------------------------+------------------------------+------------------------------+ | **Volume** |CUBIC_METER |_m3 | + +------------------------------+------------------------------+ | |CUBIC_DECIMETER |_dm3 | + +------------------------------+------------------------------+ | |CUBIC_CENTIMETER |_cm3 | + +------------------------------+------------------------------+ | |CUBIC_MILLIMETER |_mm3 | + +------------------------------+------------------------------+ | |CUBIC_INCH |_in3 | + +------------------------------+------------------------------+ | |CUBIC_FOOT |_ft3 | + +------------------------------+------------------------------+ | |CUBIC_YARD |_yd3 | + +------------------------------+------------------------------+ | |CUBIC_TILE |_tl3 | +------------------------------+------------------------------+------------------------------+ | **Velocity** |METER_PER_SECOND |_mps | + +------------------------------+------------------------------+ | |FOOT_PER_SECOND |_fps | +------------------------------+------------------------------+------------------------------+ | **Acceleration** |METER_PER_SECOND_SQUARED |_mps2 | +------------------------------+------------------------------+------------------------------+ | **Jerk** |METER_PER_SECOND_CUBED |_mps3 | +------------------------------+------------------------------+------------------------------+ | **Angular Velocity** |RADIAN_PER_SECOND |_radps | + +------------------------------+------------------------------+ | |DEGREE_PER_SECOND |_degps | +------------------------------+------------------------------+------------------------------+ | **Angular Acceleration** |RADIAN_PER_SECOND_SQUARED |_radps2 | + +------------------------------+------------------------------+ | |DEGREE_PER_SECOND_SQUARED |_degps2 | +------------------------------+------------------------------+------------------------------+ | **Angular Jerk** |RADIAN_PER_SECOND_CUBED |_radps3 | + +------------------------------+------------------------------+ | |DEGREE_PER_SECOND_CUBED |_degps3 | +------------------------------+------------------------------+------------------------------+ | **Force** |NEWTON |_newton | +------------------------------+------------------------------+------------------------------+ | **Torque** |NEWTON_METER |_Nm | +------------------------------+------------------------------+------------------------------+